package leetcode.D700.T680;

class Solution {
    public boolean validPalindrome(String s) {
        int left = 0, right = s.length()-1;
        while(left < right) {
            if(s.charAt(left) == s.charAt(right)) {
                left++;
                right--;
            } else {
                return isPal(s.substring(left+1, right+1)) || isPal(s.substring(left, right));
            }
        }
        return true;
    }
    boolean isPal(String s) {
        int left = 0, right = s.length()-1;
        while(left < right) {
            if(s.charAt(left++) != s.charAt(right--)) {
                return false;
            }
        }
        return true;
    }
}
